package ui.swing.spinner;

import java.awt.BorderLayout;
import java.util.Date;
import java.util.Calendar;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerDateModel;
import javax.swing.SpinnerModel;
import javax.swing.border.EmptyBorder;

public class SpinnerDemoDate extends JFrame {

	private static final long serialVersionUID = 4288033784542884111L;

	public SpinnerDemoDate() {
		super("Spinner Demo (Date)");

		JPanel p = new JPanel();
		p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
		p.setBorder(new EmptyBorder(10, 10, 10, 10));

		p.add(new JLabel("Select Date:"));
		SpinnerModel model = new SpinnerDateModel(new Date(), // initial value
				null, // Minimum value - not set
				null, // Maximum value - not set
				Calendar.DAY_OF_MONTH // Step
		);
		JSpinner spn = new JSpinner(model);
		p.add(spn);

		getContentPane().add(p, BorderLayout.NORTH);
		setSize(400, 75);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}

	public static void main(String[] args) {
		new SpinnerDemoDate();
	}
}